/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author GiangLT
 */
@Entity
@Table(name = "OMAP_RESOURCE", catalog = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OmapResource.findAll", query = "SELECT r FROM OmapResource r"),
    @NamedQuery(name = "OmapResource.findById", query = "SELECT r FROM OmapResource r WHERE r.id = :id"),
    @NamedQuery(name = "OmapResource.findByName", query = "SELECT r FROM OmapResource r WHERE r.name = :name"),
    @NamedQuery(name = "OmapResource.findByDescription", query = "SELECT r FROM OmapResource r WHERE r.description = :description")})
public class OmapResource implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private BigDecimal id;
    @Size(max = 200)
    @Column(name = "NAME")
    private String name;
    @Size(max = 1000)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(mappedBy = "resourceId")
    private List<Permission> permissionList;

    public OmapResource() {
    }

    public OmapResource(BigDecimal id) {
        this.id = id;
    }

    public BigDecimal getId() {
        return id;
    }

    public void setId(BigDecimal id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<Permission> getPermissionList() {
        return permissionList;
    }

    public void setPermissionList(List<Permission> permissionList) {
        this.permissionList = permissionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OmapResource)) {
            return false;
        }
        OmapResource other = (OmapResource) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.thienloc.omap.entity.OmapResource[ id=" + id + " ]";
    }
    
}
